import { defineStore } from 'pinia'
import { getCartList } from '@/api/cart'
type CartItem = {
  proid: string
  num: number
  flag: boolean
  originprice: number
  proname: string
  img1: string
  cartid: string
}
export const useCartStore = defineStore({
  id: 'cart',
  state: () => ({
    cartList: <Array<CartItem>>[]
  }),
  actions: {
    updateCartList() {

    },
    getCartListData(userid: string) {
      getCartList({
        userid,
      }).then((res: any) => {
        // this.isLoading = false; 组件内部去处理
        if (res.code !== "10020") {
          this.cartList = res.data;
        }
      }).catch((err) => {
        console.error(err);
      });
    },
  }
})
